package com.fhzn.auth.web;

import com.fhzn.auth.entity.WebResponse;
import com.fhzn.auth.service.UserDataResourceService;
import com.fhzn.auth.web.request.GrantUserDataResourceRequest;
import com.fhzn.auth.web.request.UserDataResourceRequest;
import lombok.RequiredArgsConstructor;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 老顾
 * @apiNote
 * @since 2024/1/18
 */
@RestController
@RequestMapping("/dataResource")
@RequiredArgsConstructor
public class UserDataResourceController {

    private final UserDataResourceService userDataResourceService;

    @GetMapping("/queryUserByCode")
    public WebResponse<List<String>> getUsersByDataResource(@Validated @ParameterObject UserDataResourceRequest request) {
        return WebResponse.success(userDataResourceService.getUsersByDataResource(request));
    }

    @PostMapping("/deleteAndGrantDataResource")
    public WebResponse<String> deleteAndGrantDataResource(@Validated @RequestBody GrantUserDataResourceRequest request) {
        return WebResponse.success(userDataResourceService.deleteAndGrantDataResource(request));
    }

}
